﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Etapa1.BindKey;
using Etapa1.Objects;
using PloobsEngine.Physics;
using PloobsEngine.SceneControl;
using PloobsEngine.Input;
using PloobsEngine.Modelo;
using Microsoft.Xna.Framework;
using PloobsEngine.Material;
using PloobsEngine.Cameras;
using PloobsEngineDemo3;
using PloobsEngine;
using PloobsEngine.Particle3D;
using PloobsEngine.Draw;
using PloobsEngine.Loader;
using PloobsEngine.Light;
using Microsoft.Xna.Framework.Graphics;
using PloobsEngine.Physics.XJigLib;

namespace Etapa1.Screens
{
    public class SceneSampleScreen : SceneScreen
    {
        private JigLibxWorld physicWorld;
        private BrutalForceWorld mundo;
        private EngineStuff engine;        
        ICamera cam;

        // This sample uses five different particle systems.
        ParticleSystem explosionParticles;
        ParticleSystem explosionSmokeParticles;
        ParticleSystem projectileTrailParticles;
        ParticleSystem smokePlumeParticles;
        ParticleSystem fireParticles;
        Vector3 particlesPos = new Vector3(100, 50, 100);

        public SceneSampleScreen(EngineStuff es)
        {
            this.engine = es;
            physicWorld = new JigLibxWorld(new GenericDebugDrawn(engine));            
            mundo = new BrutalForceWorld(physicWorld);                        
            engine.Game.IsFixedTimeStep = true;
        }

        
        public override void LoadContent(EngineStuff es)
        {            
            InputAdvanced inp = new InputAdvanced(engine);
            engine.AddComponent(inp);

            Drawing.setClearEveryFrame(false);

            base.LoadContent(es);
            explosionParticles = new ExplosionParticleSystem(engine);
            explosionSmokeParticles = new ExplosionSmokeParticleSystem(engine);
            projectileTrailParticles = new ProjectileTrailParticleSystem(engine);
            smokePlumeParticles = new SmokePlumeParticleSystem(engine);
            fireParticles = new FireParticleSystem(engine);

            mundo.ParticleManager.AddParticleSystem(explosionParticles);
            mundo.ParticleManager.AddParticleSystem(explosionSmokeParticles);
            mundo.ParticleManager.AddParticleSystem(projectileTrailParticles);
            mundo.ParticleManager.AddParticleSystem(smokePlumeParticles);
            mundo.ParticleManager.AddParticleSystem(fireParticles);

            //BombsEmiter me = new BombsEmiter(new Vector3(-20, 10,150));
            //mundo.ParticleManager.AddEmiter(me);

            //me = new BombsEmiter(new Vector3(20, 10, 150));
            //mundo.ParticleManager.AddEmiter(me);

            //CircleOfFireEmiter cofe = new CircleOfFireEmiter(new Vector3(-20,30,50));
            //mundo.ParticleManager.AddEmiter(cofe);

            //SmokeEmiter se = new SmokeEmiter(new Vector3(0, 1, 150));
            //mundo.ParticleManager.AddEmiter(se);

            #region Models

            //{         
                
            //    AnimatedModel am = new AnimatedModel("..\\Content\\Model\\glauquinho");
            //    am.LoadModelo();

            //    SerializeCollisionSkinInfoJigLibX sci2 = new SerializeCollisionSkinInfoJigLibX(@"Content\\CollisionInfo\\char.xml", engine, mundo);
            //    CharacterObject pi = (CharacterObject)sci2.DeSerialize(new Vector3(150,40,-150), Matrix.Identity,am);
            //    //pi.Rotation = Matrix.CreateRotationX(MathHelper.ToRadians(90));
            //    AnimatedController ac = new AnimatedController(am, "stand");
            //    ac.MappActionAnimation(CharacterMovimentationBehavior.MOVEBACK, "walk");
            //    ac.MappActionAnimation(CharacterMovimentationBehavior.MOVELEFT, "walk");
            //    ac.MappActionAnimation(CharacterMovimentationBehavior.MOVERIGHT, "walk");
            //    ac.MappActionAnimation(CharacterMovimentationBehavior.MOVEFRONT, "walk");
            //    ac.MappActionAnimation(CharacterMovimentationBehavior.STOPPED, "stand");
            //    ac.MappActionAnimation(CharacterMovimentationBehavior.STOPPING, "stand");

            //    SimpleAnimationShader sas = new SimpleAnimationShader(ac);                
            //    sas.Initialize(engine);
            //    AnimatedMaterial mat = new AnimatedMaterial(ac, sas, MaterialType.DEFERRED);
                
            //    IObject obj4 = new SimpleObject(mat, pi, am);
            //    mundo.AddObject(obj4);


            //    Engine.Behavior.KeyboardBehaviors bh = new Engine.Behavior.KeyboardBehaviors();

            //    HardCharacterMovimentationBehavior cmb = new HardCharacterMovimentationBehavior(engine, pi);
            //    cmb.setSpeed(150);

            //    bh.MapStringToBehavior(cmb, CharacterMovimentationBehavior.MOVEBACK);
            //    bh.MapStringToBehavior(cmb, CharacterMovimentationBehavior.MOVERIGHT);
            //    bh.MapStringToBehavior(cmb, CharacterMovimentationBehavior.MOVELEFT);
            //    bh.MapStringToBehavior(cmb, CharacterMovimentationBehavior.MOVEFRONT);
            //    cmb.Attach(ac);

            //    bh.MapKeyBehavior(Keys.K, Engine.Input.StateKey.DOWN, cmb, CharacterMovimentationBehavior.MOVEBACK);
            //    bh.MapKeyBehavior(Keys.L, Engine.Input.StateKey.DOWN, cmb, CharacterMovimentationBehavior.MOVERIGHT);
            //    bh.MapKeyBehavior(Keys.J, Engine.Input.StateKey.DOWN, cmb, CharacterMovimentationBehavior.MOVELEFT);
            //    bh.MapKeyBehavior(Keys.I, Engine.Input.StateKey.DOWN, cmb, CharacterMovimentationBehavior.MOVEFRONT);
            //    obj4.Behavior = bh;



            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\senario", "..\\Content\\Textures\\brickwork", "..\\Content\\Textures\\brickwork_normal");
            //    //SimpleModel sm = new SimpleModel("..\\Content\\Model\\cenario");
            //    sm.LoadModelo();
            //    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, Vector3.Zero);
            //    pi.isMotionLess = true;
            //    CustomDeferred shader = new CustomDeferred(false, true, false, false);                
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}
            //{
            //    IModelo character = new SimpleModel("..\\Content\\Model\\block", "..\\Content\\Textures\\crackedp");
            //    character.LoadModelo();
            //    IPhysicObject pi = new BoxObject(new Vector3(1), new Vector3(140, 120, -200), Matrix.Identity, new Vector3(40));
            //    pi.isMotionLess = true;
            //    ///Create a shader 
            //    IShader shader2 = new NormalDeferred();
            //    NormalDeferredFakeShadowParcial nf = new NormalDeferredFakeShadowParcial();
            //    shader2.PartialShader = nf;
            //    shader2.Initialize(engine);
            //    ///Create a Material
            //    IMaterial mat2 = new Material(shader2, MaterialType.ALLBITON);
            //    mat2.CastShadow = true;
            //    IObject objChar = new SimpleObject(mat2, pi, character);
            //    mundo.AddObject(objChar);

            //}
            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\block", "..\\Content\\Textures\\crackedp");
            //    sm.BumpMapName = "..\\Content\\Textures\\crackedp_N";
            //    sm.ParalaxName = "..\\Content\\Textures\\crackedp_H";
            //    sm.LoadModelo();
            //    IPhysicObject pi = new BoxObject(new Vector3(1), new Vector3(250, 50, 150), Matrix.Identity, new Vector3(40));
            //    pi.isMotionLess = true;
            //    //BumpDeffered shader = new BumpDeffered();
            //    CustomDeferred shader = new CustomDeferred(false, true, false, true);
            //    shader.SpecularIntensity = 0;
            //    shader.SpecularPower = 0;
            //    //GlowDiffuseDeferred shader = new GlowDiffuseDeferred();
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\block", "..\\Content\\Textures\\crackedp");
            //    sm.BumpMapName = "..\\Content\\Textures\\crackedp_N";
            //    sm.ParalaxName = "..\\Content\\Textures\\crackedp_H";
            //    sm.LoadModelo();
            //    IPhysicObject pi = new BoxObject(new Vector3(1), new Vector3(250, 50, 250), Matrix.Identity, new Vector3(40));
            //    pi.isMotionLess = true;
            //    BumpDeffered shader = new BumpDeffered();
            //    //CustomDeferred shader = new CustomDeferred(false, false, false);         
            //    //GlowDiffuseDeferred shader = new GlowDiffuseDeferred();
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\block", "..\\Content\\Textures\\diffuse");
            //    sm.LoadModelo();
            //    IPhysicObject pi = new BoxObject(new Vector3(1), new Vector3(250, 50, 320), Matrix.Identity, new Vector3(40));
            //    pi.isMotionLess = true;
            //    NormalDeferred shader = new NormalDeferred();
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\block", "..\\Content\\Textures\\brick");
            //    sm.BumpMapName = "..\\Content\\Textures\\brick_normal";
            //    sm.ParalaxName = "..\\Content\\Textures\\brick_bump";
            //    sm.LoadModelo();
            //    IPhysicObject pi = new BoxObject(new Vector3(1), new Vector3(250, 50, 420), Matrix.Identity, new Vector3(40));
            //    pi.isMotionLess = true;
            //    CustomDeferred shader = new CustomDeferred(false, true, false, true);
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\block", "..\\Content\\Textures\\brickwork", "..\\Content\\Textures\\brickwork_normal");
            //    sm.LoadModelo();
            //    IPhysicObject pi = new BoxObject(new Vector3(1), new Vector3(450, 50, 420), Matrix.Identity, new Vector3(40));
            //    pi.isMotionLess = true;
            //    BumpDeffered shader = new BumpDeffered();
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}




            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\box", "..\\Content\\Textures\\transparent");
            //    sm.LoadModelo();
            //    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, new Vector3(50, 50, 50),new Vector3(5));
            //    pi.isMotionLess = true;
            //    TransparenteNormal shader = new TransparenteNormal();
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.FORWARD);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\box");
            //    sm.LoadModelo();
            //    IPhysicObject pi = new GhostObject(new Vector3(50, 50, 50), Matrix.Identity,  new Vector3(5));
            //    pi.isMotionLess = true;
            //    NormalDeferred shader = new NormalDeferred();
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            #endregion

            #region Cenario

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\factory");
            //    sm.LoadModelo();
            //    //IPhysicObject pi = new GhostObject(new Vector3(50, 50, 50), Matrix.Identity, new Vector3(5));
            //    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, Vector3.Zero);
            //    pi.isMotionLess = true;
            //    NormalDeferred shader = new NormalDeferred();
            //    shader.SpecularIntensity = 0.5f;
            //    shader.SpecularPower = 0.1f;
            //    //NormalDeferredFakeShadowParcial xx = new NormalDeferredFakeShadowParcial();
            //    //xx.ShadownAlpha = 0.5f;
            //    //xx.Ground = new Plane(new Vector3(0, -1, 0), 0);
            //    //shader.PartialShader = xx;                
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            ////{
            ////    SimpleModel sm = new SimpleModel("..\\Content\\Model\\muro");
            ////    sm.BumpMapName = "..\\Content\\Textures\\brick_normal";
            ////    sm.DiffuseMapName = "..\\Content\\Textures\\brickwork_normal";                
            ////    sm.LoadModelo();                
            ////    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, Vector3.Zero);
            ////    pi.isMotionLess = true;
            ////    CustomDeferred shader = new CustomDeferred(false,true, false, false);
            ////    shader.Initialize(engine);
            ////    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            ////    IObject obj4 = new SimpleObject(mat, pi, sm);
            ////    mundo.AddObject(obj4);
            ////}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\grass");
            //    sm.BumpMapName = "..\\Content\\Textures\\grass_normal";
            //    sm.DiffuseMapName = "..\\Content\\Textures\\grass";
            //    sm.SpecularMapName = "..\\Content\\Textures\\grass_specular";
            //    sm.LoadModelo();
            //    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, Vector3.Zero);
            //    pi.isMotionLess = true;
            //    CustomDeferred shader = new CustomDeferred(false, true, true, false);
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\factory_interior");
            //    sm.DiffuseMapName = "..\\Content\\Textures\\chao";
            //    sm.LoadModelo();
            //    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, Vector3.Zero);
            //    pi.isMotionLess = true;
            //    NormalDeferred shader = new NormalDeferred();
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\door");
            //    sm.DiffuseMapName = "..\\Content\\Textures\\chao";
            //    sm.LoadModelo();
            //    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, Vector3.Zero);
            //    pi.isMotionLess = true;
            //    NormalDeferred shader = new NormalDeferred();
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\cilos");
            //    sm.DiffuseMapName = "..\\Content\\Textures\\oilank";
            //    sm.LoadModelo();
            //    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, Vector3.Zero);
            //    pi.isMotionLess = true;
            //    EMReflective shader = new EMReflective("..\\Content\\Textures\\cubeMap", 0.7f);
            //    shader.SpecularPower = 1;
            //    shader.SpecularIntensity = 1;
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\chao");
            //    sm.DiffuseMapName = "..\\Content\\Textures\\chao";
            //    sm.LoadModelo();
            //    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, Vector3.Zero);
            //    pi.isMotionLess = true;
            //    NormalDeferred shader = new NormalDeferred();
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\pipe");
            //    sm.DiffuseMapName = "..\\Content\\Textures\\pipe";
            //    sm.LoadModelo();
            //    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, Vector3.Zero);
            //    pi.isMotionLess = true;
            //    NormalDeferred shader = new NormalDeferred();
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\truck");
            //    sm.DiffuseMapName = "..\\Content\\Textures\\lorry";
            //    sm.GlowName = "..\\Content\\Textures\\lorry_glow";
            //    sm.LoadModelo();
            //    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, Vector3.Zero);
            //    pi.isMotionLess = true;
            //    CustomDeferred shader = new CustomDeferred(true, false, false, false);
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\caixa");
            //    sm.DiffuseMapName = "..\\Content\\Textures\\diffuse";
            //    sm.GlowName = "..\\Content\\Textures\\glow";
            //    sm.LoadModelo();
            //    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, Vector3.Zero);
            //    pi.isMotionLess = true;
            //    CustomDeferred shader = new CustomDeferred(true, false, false, false);
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}

            //{
            //    SimpleModel sm = new SimpleModel("..\\Content\\Model\\post");
            //    sm.LoadModelo();
            //    IPhysicObject pi = new TriangleMeshObject(sm, Matrix.Identity, Vector3.Zero);
            //    pi.isMotionLess = true;
            //    EMReflective shader = new EMReflective("..\\Content\\Textures\\cubeMap", 0.5f);
            //    shader.Initialize(engine);
            //    IMaterial mat = new Material(shader, MaterialType.DEFERRED);
            //    IObject obj4 = new SimpleObject(mat, pi, sm);
            //    mundo.AddObject(obj4);
            //}
            #endregion

            #region Loader

            ExtractXmlModelLoader me = new ExtractXmlModelLoader();
            ModelLoaderData data = me.Load("sponza");

            foreach (var item in data.ModelMeshesInfo)
            {
                ComposedPartsModel sm = new ComposedPartsModel(item);
                sm.LoadModelo();
                IPhysicObject pi = new TriangleMeshObject(sm, Matrix.CreateFromQuaternion(item.ori), item.pos, item.scale);
                pi.isMotionLess = true;
                CustomDeferred shader = new CustomDeferred(item.HasTexture(TextureType.GLOW), item.HasTexture(TextureType.BUMP), item.HasTexture(TextureType.SPECULAR), item.HasTexture(TextureType.PARALAX));
                //NormalDeferred shader = new NormalDeferred();
                shader.Initialize();
                IMaterial mat = new Material(shader, MaterialType.DEFERRED);
                IObject obj4 = new SimpleObject(mat, pi, sm);
                mundo.AddObject(obj4);
            }

            foreach (var item in data.LightsInfo)
            {
                mundo.AddLight(item);
            }

            #endregion

            cam = new CameraFirstPerson(true);
            //cam = new StaticCamera(new Vector3(100,50,100), Vector3.Zero);
            cam.FarPlane = 3000;
            
            LightThrow lt = new LightThrow(mundo,engine);         
    
            /////Luz do poste
            //SpotLight sl = new SpotLight(new Vector3(-56, 700, 30), new Vector3(0.1f,-0.8f,0.3f) , 1f, 100000, Color.White, (float)Math.Cos(Math.PI / 3), 1f);
            //sl.CastShadown = true;
            //mundo.AddLight(sl);

            //#region Shadow LIGHT
            ////LightDirectional ld = new LightDirectional(new Vector3(-1), Color.White);
            ////LightDirectional ld2 = new LightDirectional(new Vector3(-0.3f, -1, -0.3f), Color.White);
            ////LightDirectional ld3 = new LightDirectional(Vector3.Down, Color.White);
            ////ld.LightIntensity = 0.3f;
            ////ld2.LightIntensity = 0.3f;
            ////ld3.LightIntensity = 0.3f;
            ////ld.CastShadown = true;
            ////ld2.CastShadown = false;
            ////ld3.CastShadown = false;
            ////mundo.AddLight(ld);
            ////mundo.AddLight(ld2);
            ////mundo.AddLight(ld3);
            //#endregion

            #region NormalLight
            DirectionalLight ld1 = new DirectionalLight(Vector3.Left, Color.White);
            DirectionalLight ld2 = new DirectionalLight(Vector3.Right, Color.White);
            DirectionalLight ld3 = new DirectionalLight(Vector3.Backward, Color.White);
            DirectionalLight ld4 = new DirectionalLight(Vector3.Forward, Color.White);
            DirectionalLight ld5 = new DirectionalLight(Vector3.Down, Color.White);
            float li = 0.4f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            mundo.AddLight(ld1);
            mundo.AddLight(ld2);
            mundo.AddLight(ld3);
            mundo.AddLight(ld4);
            mundo.AddLight(ld5);
            #endregion

            ////Criacao de uma Tecnica
            DeferredRenderTechnic dr = new DeferredRenderTechnic(engine);

            //SSAOPostEffect s = new SSAOPostEffect();
            //s.EnableControl = false;
            //s.WhiteCorrection = 0.7f;
            //s.Intensity = 5;
            //s.Diffscale = 0.5f;
            ////s.OutputONLYSSAOMAP = true;
            //dr.AddPostEffect(s);

            //dr.AddPostEffect(new GlowPostEffect());

            //AntiAliasingPostEffect aa = new AntiAliasingPostEffect();
            //dr.AddPostEffect(aa);

            //HdrPostEffect h = new HdrPostEffect();
            //dr.AddPostEffect(h);

            //DephtOfFieldPostEffect dof = new DephtOfFieldPostEffect();
            //dof.Distance = 200;
            //dof.Range = 90;
            //dr.AddPostEffect(dof);            


            //FogPostEffect fog = new FogPostEffect(cam.NearPlane, 850);
            //fog.FogColor = Color.LightGray;
            //dr.AddPostEffect(fog);

            //ToonPostEffect to = new ToonPostEffect();
            //dr.AddPostEffect(to);

            //BloomPostEffect bloom = new BloomPostEffect();
            //dr.AddPostEffect(bloom);


            //dr.AddPostEffect(new Teste());
            //dr.AddPostEffect(new OpacityMapPostEffect("..\\Content\\Textures\\opacitymap"));            
            //dr.RestoreDepth = true;            
            //dr.isPhysicDebug = true;
            //dr.isDebug = true;      

            //dr.isDebug = true;
            IRenderTechnic[] rt = new IRenderTechnic[] { dr };
            dr.DeferredFinalCombination.AmbientColor = new Color(0.1f, 0.1f, 0.1f);
            ShadowLightMap slm = new ShadowLightMap();
            slm.ShadownBufferSize = 2048;
            //dr.DeferredLightMap = slm;
            //dr.isDebug = true;
            this.RenderTechnics = rt;
            mundo.AddCamera(cam);
            this.World = mundo;

            //Skybox sb = new Skybox(engine);            
            //engine.AddComponent(sb);

            //SkyBoxUpdateParametersCommand suc = new SkyBoxUpdateParametersCommand(cam);
            //suc.setStyle(Skybox.SkyType.TOON);
            //CommandProcessor.getCommandProcessor().SendCommandAssyncronous(suc);


        }

  



    }
}

